package com.ow.module.event.caseHistoryMgr;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ow.framework.common.Constant;
import com.ow.framework.data.po.ResultData;
import com.ow.framework.listener.event.EventExecutor;
import com.ow.framework.listener.event.EventListener;

public class QueryAssertInfo  implements EventListener {
	static Logger log = Logger.getLogger(Constant.FRAMEWORK);
	 
	public ResultData event(EventExecutor eventExecutor) throws Exception {
		ResultData returnData =   new ResultData();
		// TODO Auto-generated method stub
		String sid = eventExecutor.getSqlidByIndex(0);
		HashMap<String,String> paramMap = eventExecutor.getBaseAction().getParamMap();
		String caseHistoryId = paramMap.get("caseHistoryID");
		HashMap initTempMap = new HashMap();
		initTempMap.put("aaCaseHistoryId", caseHistoryId);
		initTempMap.put("caseHistoryID", caseHistoryId);
		//caseHistory.select_caseHistory_by_id_heaq   
		HashMap baseInfoMap = (HashMap) eventExecutor.getSqlSession().selectOne("caseHistory.select_caseHistory_by_id_heaq", initTempMap);
		
		 List rrlist = eventExecutor.getSqlSession().selectList("assertAnswer.sel_new_time", initTempMap);
		 if(rrlist!=null &&rrlist.size()>0){
			String  suptime=  rrlist.get(0).toString();
			baseInfoMap.put("suptime", suptime);
		 }
		 returnData.setOne(baseInfoMap);
		 List<HashMap> rlist = eventExecutor.getSqlSession().selectList("assertAnswer.sel_answered_paper_heaq",initTempMap );
		List  returnList = new ArrayList();
		for (HashMap map : rlist) {
			HashMap resMap = new HashMap();
			Map selScoreMap = new HashMap();
			selScoreMap.put("aaAssertPid", map.get("aaAssertPid"));
			selScoreMap.put("aaAsertTimes", map.get("aaAsertTimes"));
			selScoreMap.put("aaCaseHistoryId",caseHistoryId  );
			selScoreMap.put("answerIdList", "('23','28','33','38','43','48','53')");
			resMap.putAll(map);
			
			
			int scoreA = (Integer)eventExecutor.getSqlSession().selectOne("assertAnswer.sel_paper_score_heaq", selScoreMap);
			resMap.put("scoreA", scoreA);
			
			selScoreMap.remove("answerIdList");
			selScoreMap.put("answerIdList", "('59','64','69','74','79','84','89')");
			int scoreD = (Integer)eventExecutor.getSqlSession().selectOne("assertAnswer.sel_paper_score_heaq", selScoreMap);
			resMap.put("scoreD", scoreD);
			returnList.add(resMap);
			
		}
		returnData.setList(returnList);
		return returnData;
	}

}
